#include "ThreadPool.hpp"
#include "Task.hpp"
#include "Log.hpp"
#include <iostream>
#include <string>
#include <memory> // 包含了一些智能指针
#include <ctime>

int main()
{
    EnableFile();
    LOG(INFO, "程序已加载");
    sleep(1);
    ThreadPool<Task> *tp = ThreadPool<Task>::GetInstance();
    srand(time(nullptr) ^ getpid() ^ pthread_self());
    // EnableScreen(); // 开启日志显示器打印功能
    int tasknum = 10;
    while (tasknum)
    {
        int a = rand() % 10 + 1;
        usleep(1234);
        int b = rand() % 5 + 1;
        Task t(a, b);
        LOG(INFO, "main thread push task: %s", t.DebugToString().c_str());
        tp->Enqueue(t);
        // sleep(1);
        tasknum--;
    }
    tp->Stop();
    tp->Wait();

    return 0;
}